//
//  WSLessonTicketAlertView.m
//  WisdomStar
//
//  Created by 谭飞 on 2018/10/31.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "WSLessonTicketAlertView.h"

@interface WSLessonTicketAlertView ()

@property (weak, nonatomic) IBOutlet UILabel *alertTitleLabel;
@property (weak, nonatomic) IBOutlet UIView *inputView;
@property (weak, nonatomic) IBOutlet UIButton *confirmBtn;
@property (weak, nonatomic) IBOutlet UIButton *cancleBtn;
@property (weak, nonatomic) IBOutlet UITextField *inputTextField;


@end

@implementation WSLessonTicketAlertView

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5f];
    [self.inputView setRoundBorder:COLOR_HEX(0xcccccc) radius:3.f];
    [self.confirmBtn setCorners:UIRectCornerAllCorners cornerRadius:self.confirmBtn.xmg_height/2];
    [self.cancleBtn setRoundBorder:kThemeGreenColor radius:self.cancleBtn.xmg_height/2];
    
    self.alertTitleLabel.text = _type == 0 ? @"课时券兑换" : @"积分兑换";
    self.inputTextField.placeholder = _type == 0 ? @"请输入课时券数量..." : @"请输入积分数量...";
}

// show alert
- (void)show {
    self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    self.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    [KAppWindow.rootViewController presentViewController:self animated:YES completion:nil];
}

// hide alert
- (void)hide {
    [self dismissViewControllerAnimated:YES completion:nil];
}


#pragma mark - Actions

- (IBAction)confirmBtnClick:(id)sender {
    if (self.confirmBlock) {
        self.confirmBlock(self, _inputTextField.text);
    }
}

- (IBAction)cancleBtnClick:(id)sender {
    [self hide];
    if (self.cancleBlock) {
        self.cancleBlock();
    }
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
